Vue.filter("formatDate", function (target,str) {
    if (!(target instanceof Date)) {
        console.warn("formatDate是对时间对象进行格式化的方法");
        return target;
    }
    // console.log(str); // yyyy-MM-dd hh:mm:ss
    let y = target.getFullYear() + "";
    // console.log(y);
    let o = {
        "(M+)": target.getMonth() + 1 + "",
        "(d+)": target.getDate() + "",
        "(h+)": target.getHours() + "",
        "(m+)": target.getMinutes() + "",
        "(s+)": target.getSeconds() + ""
    }
    if (new RegExp("(y+)").test(str)) {
        str = str.replace(/y+/, y.substr(y.length - RegExp.$1.length, y.length));
    }
    for (const key in o) {
        let reg = new RegExp(key);
        if (reg.test(str)) {
            // 1,2,3  11 12  ==>  01 02 03  011 012 
            let rep = "";
            if (RegExp.$1.length == 1) {
                rep = o[key];
            } else {
                rep = ("0" + o[key]).substr(-2, 2);
                // console.log(rep);
            }
            str = str.replace(reg, rep);
        }
    }
    return str;
});